Let’s load some data from the Unfall dataset

setwd("~/Workspace/R/Data Science for agent-based transport simulations/week09/week09")
getwd()
## [1] "/Users/haowu/Workspace/R/Data Science for agent-based transport simulations/week09/week09"
# Second try: accident data!
unfaelle = read_csv2("Unfaelle.csv",
                     locale = locale(encod="latin1"))
## ℹ Using ',' as decimal and '.' as grouping mark. Use `read_delim()` for more control.
## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   .default = col_double(),
##   STRASSE = col_character()
## )
## ℹ Use `spec()` for the full column specifications.
## Warning: 1 parsing failure.
##   row         col expected                  actual           file
## 11894 USTRZUSTAND a double Hellersdorfer Promenade 'Unfaelle.csv'
unf_sf <- unfaelle %>%
  filter(UWOCHENTAG==4, STRASSE=="Unter den Linden Nord") %>%
  st_as_sf(coords=c("XGCSWGS84", "YGCSWGS84"), crs=4356)

Charging Stations in Berlin

This is from the Berlin city website: source data at: - http://daten.berlin.de/datensaetze/emobility-ladestationen-berlin

# E-charging stations: need to find EPSG for this dataset!
# it is not 3068 or 31468
data <- read_excel("ladesaeulen.xlsx", sheet="Sachdaten")
data
charging_stations <- st_as_sf(data, coords=c("x_wert", "y_wert"), crs=25833)
# charging_stations
# plot(charging_stations)

# read neighborhood shapefile
bezirke = st_read("shp-bezirke/bezirke_berlin.shp")
## Reading layer `bezirke_berlin' from data source `/Users/haowu/Workspace/R/Data Science for agent-based transport simulations/week09/week09/shp-bezirke/bezirke_berlin.shp' using driver `ESRI Shapefile'
## Simple feature collection with 23 features and 1 field
## geometry type:  POLYGON
## dimension:      XY
## bbox:           xmin: 4574148 ymin: 5801817 xmax: 4619867 ymax: 5839097
## projected CRS:  DHDN_3_degree_Gauss_Kruger_zone_4
bezirke <- st_read("shp-bezirke/bezirke_berlin.shp")
## Reading layer `bezirke_berlin' from data source `/Users/haowu/Workspace/R/Data Science for agent-based transport simulations/week09/week09/shp-bezirke/bezirke_berlin.shp' using driver `ESRI Shapefile'
## Simple feature collection with 23 features and 1 field
## geometry type:  POLYGON
## dimension:      XY
## bbox:           xmin: 4574148 ymin: 5801817 xmax: 4619867 ymax: 5839097
## projected CRS:  DHDN_3_degree_Gauss_Kruger_zone_4
bezirke
plot(bezirke)

# make interactive
tmap_mode("view")
## tmap mode set to interactive viewing
tm_shape(charging_stations) +
  tm_symbols(size=1)
tm_shape(bezirke) +
  tm_polygons() +
  tm_shape(charging_stations) +
  tm_symbols(size=0.01, id="STRASSE")